using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class WishListInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			UserID,
			ProductID,
			DateTime,
			Status
		}
		private Int64 _ID;
		private Int32 _UserID;
		private Int32 _ProductID;
		private DateTime _DateTime;
		private Int32 _Status;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public Int32 UserID{	get{ return _UserID;} set{_UserID = value;} }
		public Int32 ProductID{	get{ return _ProductID;} set{_ProductID = value;} }
		public DateTime DateTime{	get{ return _DateTime;} set{_DateTime = value;} }
		public Int32 Status{	get{ return _Status;} set{_Status = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public WishListInfo()
		{
			_ID = 0;
			_UserID = 0;
			_ProductID = 0;
			_DateTime = DateTime.Now;
			_Status = 0;
		}
		public WishListInfo(
		Int64 ID,
		Int32 UserID,
		Int32 ProductID,
		DateTime DateTime,
		Int32 Status
		)
		{
			_ID = ID;
			_UserID = UserID;
			_ProductID = ProductID;
			_DateTime = DateTime;
			_Status = Status;
		}
		public WishListInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_UserID = dr[Field.UserID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.UserID.ToString()]);
				_ProductID = dr[Field.ProductID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ProductID.ToString()]);
				_DateTime = dr[Field.DateTime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.DateTime.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Status.ToString()]);
			}
		}
		public WishListInfo(WishListInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_UserID = objEntr.UserID;			
			_ProductID = objEntr.ProductID;			
			_DateTime = objEntr.DateTime;			
			_Status = objEntr.Status;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("WishList");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.UserID.ToString(), typeof(Int32)),
				new DataColumn(Field.ProductID.ToString(), typeof(Int32)),
				new DataColumn(Field.DateTime.ToString(), typeof(DateTime)),
				new DataColumn(Field.Status.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.UserID.ToString()] = _UserID;
			row[Field.ProductID.ToString()] = _ProductID;
			row[Field.DateTime.ToString()] = _DateTime;
			row[Field.Status.ToString()] = _Status;
			return row;
		}
        #endregion InitTable
    }
}
